package cn.yanjr.wechat.test.dao.impl;

import org.apache.commons.dbutils.QueryRunner;

import cn.yanjr.common.dao.JDBCUtils;
import cn.yanjr.wechat.test.dao.WeChatContentDao;
import cn.yanjr.wechat.test.entity.WeChatContent;

public class WeChatContentDaoImpl implements WeChatContentDao {

	@Override
	public int save(WeChatContent wechatContent) {
		// 添加用户的sql
		String sql = "insert into wechat_content values(null,?,?,?,?,?,?) ";
		// 用JDBCUtils工具创建一个queryRunner对象
		QueryRunner queryRunner = new QueryRunner(JDBCUtils.getDataSource());
		int result = 0;
		try {
			// 用queryRunner保存用户信息
			result = queryRunner.update(sql, 
					wechatContent.getContent(),
					wechatContent.getCreateTime(),
					wechatContent.getToUserName(),
					wechatContent.getFromUserName(),
					wechatContent.getMsgType(),
					wechatContent.getMsgId());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}

}
